package com.twu.biblioteca;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class mainScreen  {
    private static bookCatalogue initialList;
    private static movieCatalogBuilder movieCatalog;
    private static userStore currentUserList;
    public static void main(String args[]) throws IOException{

        String nextOperation;
        //Create an initial book and movie  Store
        setUpInitialBookStore();
        setUpInitialMovieStore();
        setUpInitialUserStore();

        //create and display startup menu
        do{
            menuOnStartup welcomeMenu = new menuOnStartup(initialList,movieCatalog,currentUserList);
            welcomeMenu.printMenu();
            //Take and validate user input
            checkUserInput check = new checkUserInput(System.in);
            int choice = check.takeUserInput();
            welcomeMenu.isOptionValid(choice);
            System.out.println("\nSee Menu Again Yes/No");
            BufferedReader bufferRead = new BufferedReader(new InputStreamReader(System.in));
            nextOperation = bufferRead.readLine();
        }while (!nextOperation.contains("n"));
    }

    public static void setUpInitialMovieStore(){

        movieCatalog = new movieCatalogBuilder();
        movieCatalog.addMovie(new movieInstance("ET",1980,"S.SpielBerg",(float)5));
        movieCatalog.addMovie(new movieInstance("Rang De Basanti",2006,"R.Hirani", (float) 4.5));
        movieCatalog.addMovie(new movieInstance("OUATIM 2",2013,"ABC",(float)0));
        movieCatalog.addMovie(new movieInstance("Aashiqui 2",2013,"Mohit Suri", (float) 3.5));
        movieCatalog.addMovie(new movieInstance("Race 2",2012,"Boman Irani",(float)3));
        movieCatalog.addMovie(new movieInstance("Munnabhai 2",2004,"R.Hirani", (float) 4.5));
        movieCatalog.addMovie(new movieInstance("3 idiots",2010,"R. Santaoshi",(float)5));
        movieCatalog.addMovie(new movieInstance("Bobby",1970,"M.K. Mishra", (float) 5));
        movieCatalog.addMovie(new movieInstance("Yaadon Ki Baarat",1980,"V. Singhania",(float)5));
        movieCatalog.addMovie(new movieInstance("Aasman Ke Taley",1982,"RD Sharma", (float) 2.5));
        movieCatalog.addMovie(new movieInstance("Silsila",1982,"Yash Chopra",(float)5));
        movieCatalog.addMovie(new movieInstance("Kuch Kuch Hota Hai",1998,"Karan Johar", (float) 5));
        movieCatalog.addMovie(new movieInstance("Kal Ho Na Ho",2007,"Karan Johar",(float)5));
        movieCatalog.addMovie(new movieInstance("Housefull 1",2005,"Rohit Shetty", (float)3.0));
        movieCatalog.addMovie(new movieInstance("Housefull 2",2013,"Rohit Shetty",(float)2.75));
    }

    public static void setUpInitialBookStore(){

        initialList = new bookCatalogue();
        Book book1 = new Book("Shantaram",1);
        Book book2 = new Book("Midnight's Children",2);
        Book book3 = new Book("The Casual Vacancy",3);
        //Add books to store
        initialList.addBook(book1);
        initialList.addBook(book2);
        initialList.addBook(book3);

        //Create copies of books and assign them the apropriate book type
        bookItem s1 = new bookItem(false);
        bookItem s2 = new bookItem(false);
        bookItem s3 = new bookItem(false);
        s1.addBookItem(book1);
        s2.addBookItem(book2);
        s3.addBookItem(book3);
    }
    public static void setUpInitialUserStore(){

        currentUserList = new userStore();
        userInstance sampleUserOne = new userInstance("1111111","abcd","test@a.org","1234567");
        userInstance sampleUserTwo = new userInstance("1111112","123","test@b.org","6784657");
        userInstance sampleUserThree = new userInstance("1111113","234","test@c.org","9817653");
        userInstance sampleUserFour = new userInstance("1111114","345","test@d.org","98111067");
        currentUserList.addUser(sampleUserOne);
        currentUserList.addUser(sampleUserTwo);
        currentUserList.addUser(sampleUserThree);
        currentUserList.addUser(sampleUserFour);
    }
}
